import Vue from 'vue'
import Vuex from 'vuex'
import { cart } from '../views/dmallHomeIndex/module'

Vue.use(Vuex)

// mutations函数名字采用常量

const store = new Vuex.Store({
  modules: {
    cart
  }
})

// 监听到每一次mutaion提交的数据
store.subscribe((mutations, state) => {
  // 存储数据
  console.log(state, 'state----------state')
  localStorage.setItem('cart', JSON.stringify(state.cart.cartList))
})

export default store
